<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>test</title>
</head>
<body>
	<script>
		console.log('%c 没有错误输出代表全部测试通过','color:orange;font-size:5em;');
		function assert(a,b){
			console.assert(a==b);
//			if(a!=b){
//				alert('assert err');
//				console.error(a);
//			}else{
//				if(window.console)console.log(a);
//			}
		}
	</script>
	<script src="./sear-map-onefn.js"></script>
	<script>
		sear([function(next){
			setTimeout(function(){
				next(null,'one');//如果第一个参数不为null直接走最后一个函数
			},1000)
		},function(next,p){
			assert(p,'one');
			next(null,'err2');
		},function(next,p){
			//assert(1,2);
			next();
		}],function(err,p){
			assert(err,null);
		});

		parall([function(next){
			setTimeout(function(){
				next(null,2000);
			},2000);
		},function(next){
			setTimeout(function(){
				next(null,1000);
			},1000);
		},function(next){
			setTimeout(function(){
				next(null,1000);
			},1000);
		},function(next){
			setTimeout(function(){
				next(null,1000);
			},1000);
		}],function(err,r){
			assert('[2000,1000,1000,1000]',JSON.stringify(r));
		});

		map([200,1000,1,2],function(end,t,i){
			setTimeout(function(){
				end(null,t+'end');
			},t)
		},function(err,rs){
			assert(JSON.stringify(rs),'["200end","1000end","1end","2end"]');
		});

		map({key1:100,key2:200},function(end,t,key){
			setTimeout(function(){
				end(null,key+'end');
			},t)
		},function(err,rs){
			assert(JSON.stringify(rs),'{"key1":"key1end","key2":"key2end"}');
		});
        
        var a=[];
        mapsear([200,1000,1,2],function(end,t,i){
            a.push(t);
			setTimeout(function(){
                assert(a.length,i+1);
				end(null,t+'end');
			},t)
		},function(err,rs){
			assert(JSON.stringify(rs),'["200end","1000end","1end","2end"]');
		});
        
        var b=[],bi=0;
		mapsear({key1:100,key2:200},function(end,t,key){
            b.push(t);
            
			setTimeout(function(){
                bi++;
                assert(b.length,bi);
				end(null,key+'end');
			},t)
		},function(err,rs){
			assert(JSON.stringify(rs),'{"key1":"key1end","key2":"key2end"}');
		});
		
		var assert1=0;
		var fn=onefn(function(){
			assert1++;
			assert(assert1,1);
		});
		fn();
	</script>
</body>
</html>